cmake_minimum_required(VERSION 3.10.2)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

SET (CMAKE_C_COMPILER_WORKS 1)
SET (CMAKE_CXX_COMPILER_WORKS 1)
ADD_DEFINITIONS(-DMDC_PRODUCTION_CORE)

set(APP_NAME "local_sensor_data_sender")

set(CMAKE_C_FLAGS_DEBUG "")
set(CMAKE_C_FLAGS_RELEASE "")
set(CMAKE_CXX_FLAGS_DEBUG "")
set(CMAKE_CXX_FLAGS_RELEASE "")

IF (CMAKE_BUILD_TYPE MATCHES Debug)
    set(DEFAULT_COMPILE -std=c++14 -O0 -g3 -Wall -c -fmessage-length=0 -fPIC -fPIE -pie -fstack-protector-all -Wtrampolines)
ELSEIF (CMAKE_BUILD_TYPE MATCHES Release)
    set(DEFAULT_COMPILE -std=c++14 -O3 -Wall -c -fmessage-length=0 -fPIC -fPIE -pie -fstack-protector-all -Wtrampolines)
ENDIF()

add_compile_options(${DEFAULT_COMPILE})

set(MDC_ADSFI_SDK ${MDC_SDK}/sysroot/usr/include/adsfi)
set(MDC_ACLLIB_SDK ${MDC_SDK}/sysroot/usr/local/Ascend/runtime)
set(GODEL_LINK_LIBS "-lara_core -lara_com -ldl -lara_exec -lddscore -lddscpp -lJsonParser -lKeyValueStorage -llogging -lsomeip -lvcc_ddsdriver -lvcc_someipdriver -lvrtf_vcc")
set(OPENCV_LINK_LIBS "-lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml")

list_sub_dir(GENERATED_DIRS 
${CMAKE_SOURCE_DIR}/generated "${filters}")

include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/../
    ${GENERATED_DIRS}
    ${MDC_SDK}/sysroot/usr/include
    ${MDC_SDK}/sysroot/usr/include/adsfi/adb/include
    ${MDC_SDK}/sysroot/usr/include/adsfi/adsf/include
    ${MDC_SDK}/sysroot/usr/include/adsfi/arxml_include
    ${MDC_SDK}/sysroot/usr/include/yaml-cpp
    ${MDC_ACLLIB_SDK}/include
    ${MDC_ACLLIB_SDK}/include/acl
    ${MDC_ACLLIB_SDK}/include/acl/ops
    ${MDC_ACLLIB_SDK}/include/acl/dvpp
    ${THIRD_LIB_PATH}/usr/include/opencv4
    ${MDC_SDK}/sysroot/usr/include/opencv4
    ${MDC_DRIVER_SDK}/include/dvpp
    ${MDC_SDK}/sysroot/usr/include/driver
    ${MDC_SDK}/sysroot/usr/include/pcl-1.11
)

link_directories(
    ${MDC_SDK}/sysroot/lib
    ${MDC_SDK}/sysroot/usr/lib
    ${MDC_SDK}/sysroot/lib/mdc_vector
    ${MDC_SDK}/sysroot/usr/lib/mdc/base-plat
    ${MDC_ACLLIB_SDK}/lib64/stub
    ${THIRD_LIB_PATH}/usr/lib64
)

AUX_SOURCE_DIRECTORY(. IMAGE_SENDER_SRC)


set(${APP_NAME}_SOURCES
    ${IMAGE_SENDER_SRC}
)
#把目录下的c和c++所有源文件分别保存在变量中
file(GLOB_RECURSE CM_APP_FILES ${CMAKE_SOURCE_DIR}/generated/*.cpp)

add_executable(${APP_NAME} ${${APP_NAME}_SOURCES} ${CM_APP_FILES})
target_link_libraries(${APP_NAME} ${GODEL_LINK_LIBS} ${OPENCV_LINK_LIBS} rm securec log yaml-cpp ascend_hal)

target_link_libraries(${APP_NAME}
    ${OPENCV_LINK_LIBS}
    ${GODEL_LINK_LIBS}
    securec
    ascend_hal
    yaml-cpp
    log
    rm
    pthread
    acl_dvpp_mpi
    ascendcl
    stdc++
    pcl_io
    pcl_common)

install(
    TARGETS ${APP_NAME} RUNTIME
    DESTINATION ${PROJECT_SOURCE_DIR}/bin)

OPTION(SAVE_SENDER_FILE_MACRO "Build the project using macro，save local file set as ON,otherwise set OFF" ON)
if(SAVE_SENDER_FILE_MACRO)
    add_definitions("-DSAVE_SENDER_FILE")
else()
    remove_definitions("-DSAVE_SENDER_FILE")
endif()







